﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace LIMS.Web
{
    public partial class StuMessageEdit : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                #region 判断Session["studentID"]是否为空，为空就返回
                if (Session["studentID"] == null)
                {
                    this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('请不要非法操作!')", true);
                    return;
                }
                #endregion
            }
        }

        /// <summary>
        /// 将留言信息写入Message数据表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnOK_Click(object sender, EventArgs e)
        {
            if (Session["studentID"] == null)
            {
                this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('请不要非法操作!')", true);
                return;
            }
            Model.Messages message = new Model.Messages()
            {
                mesStuNo = Session["studentID"].ToString(),
                mesTitle = txtCaption.Text.Trim(),
                mesDetail = txtMessageContent.Text.Trim(),
            };
            BLL.MessageManager.AddMeeage(message);
            this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('添加留言成功!')", true);
        }




    }
}